<?php
// 函数.function,共用的代码
use JetBrains\PhpStorm\Pure;

#[Pure] function mobile($tel): string
{
    return substr($tel, 0, -4).'****';
}

echo mobile('132233231111');

echo "<br>";

function sum(int ...$args): int {
   return array_sum($args);
}

echo sum(1, 2, 3, 4, 5);

// 默认参数
function mobile2($tel, $fix = '****'): string
{
    return substr($tel, 0, -4).$fix;
}

echo mobile2(132233231111, '####');

// 具有类型的参数
function mobile3(string $tel, int $num = 4, string $fix = '*'): string
{
    return substr($tel, 0, -$num).str_repeat($fix, $num);
}

echo mobile3(132233231111);
